package logic

import (
	"camera/C/Rpc/camera"
	"context"

	"camera/C/Api/internal/svc"
	"camera/C/Api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SearEsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSearEsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearEsLogic {
	return &SearEsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SearEsLogic) SearEs(req *types.SearEsRequest) (resp *types.Response, err error) {
	// todo: add your logic here and del	ete this line
	es, err := l.svcCtx.CameraRpc.SearEs(l.ctx, &camera.SearEsRequest{FormWord: req.FormWord})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "搜索成功",
		Code: 200,
		Data: es,
	}, nil
}
